﻿#region Copyright Info

// 
// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

using System.Collections.Generic;
using Majesty_of_Omega.Config;
using System;

namespace Majesty_of_Omega.Model.Report
{
    /// <summary>
    /// A turn in the situation report. A turn groups several entries
    /// </summary>
    [Serializable]
    public class SitReportTurn
    {
        /// <summary>
        /// List of situation report entries
        /// </summary>
        private readonly List<SitReportEntry> sitReportEntries = new List<SitReportEntry>();

        /// <summary>
        /// Gets the list of sitúation report entries
        /// </summary>
        public List<SitReportEntry> SitReportEntries
        {
            get
            {
                return sitReportEntries;
            }
        }

        /// <summary>
        /// Gets or sets the turn number.
        /// </summary>
        /// <value>The turn number.</value>
        public int TurnNumber { get; set; }

        /// <summary>
        /// This function adds a situation report entry and formats the corresponding message
        /// </summary>
        /// <param name="sitReportType">The completed.</param>
        /// <param name="targetHyperLinkObject">The target hyper link object.</param>
        /// <param name="args">variable number of arguments pairs, which are depends from the type of the event.
        /// An argument consists of a variable identifier string and the value as object.
        /// <example>
        /// reportTurn.AddSitRepEntry(SitReportType.TurnCompleted, "value1", _saveGame.TurnNumber, "value2", "a suprising event text");
        /// The placeholder variables are defined in the SitRepStrings.xml
        /// </example></param>
        public void AddSitRepEntry(SitReportType sitReportType, object targetHyperLinkObject, params object[] args)
        {
            sitReportEntries.Add(new SitReportEntry(sitReportType, targetHyperLinkObject, args));
        }

        /// <summary>
        /// Equalses the specified obj.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns></returns>
        public bool Equals(SitReportTurn obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            return obj.TurnNumber == TurnNumber;
        }

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">
        /// The <paramref name="obj"/> parameter is null.
        /// </exception>
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (SitReportTurn)) return false;
            return Equals((SitReportTurn) obj);
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        public override int GetHashCode()
        {
            return TurnNumber;
        }
    }
}